package com.shopping.service.impl;

import java.util.List;
import java.util.Map;

import com.shopping.bean.Goods;
import com.shopping.bean.Page;
import com.shopping.bean.Review;
import com.shopping.dao.ReviewDao;
import com.shopping.dao.impl.ReviewDaoImpl;
import com.shopping.service.ReviewService;

public class ReviewServiceImpl implements ReviewService {

	ReviewDao rd = new ReviewDaoImpl();
	@Override
	public Page<Review> findAll(Map<String, String[]> condition) {
	List<Review> list = rd.selectAll(condition);
		
		int pageSum = rd.selectTotalRows(condition);
		int pageNum = 1;
		int pageSize = 5;
		
		try {
			pageNum = Integer.parseInt(condition.get("pageNum")[0]);
		}catch(Exception o) {
			o.printStackTrace();
		}
		try {
			pageSize = Integer.parseInt(condition.get("pageSize")[0]);
		}catch(Exception o) {
			o.printStackTrace();
		}
		System.out.println(pageNum);
		System.out.println(pageSize);
		Page<Review> page = new Page<Review>(list,pageNum,pageSize,pageSum);
		return page;
	}

}
